<%@page contentType="text/html;charset=utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>生成订单 - 当当网</title>
<link href="${pageContext.request.contextPath}/css/login.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/css/page_bottom.css" rel="stylesheet" type="text/css" />
<%--<script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>--%>
<script type="text/javascript">

</script>
</head>
<body>
	<%@include file="../common/head1.jsp"%>
	<div class="login_step">
		添加收货地址：
	</div>
	<div class="fill_message">
	
		<form name="ctl00" action="${pageContext.request.contextPath}/address/insert.do"
			method="post" id="f" onsubmit="return checkForm()">
			<input type="hidden" name="id" id="addressId" />
			<table class="tab_login">
				<tr>
					<td valign="top" class="w1">收件人姓名：</td>
					<td><input onblur="checkname()" type="text" class="text_input"
						name="name" id="receiveName" />
						<div class="text_left" id="nameValidMsg">
							<p>请填写有效的收件人姓名</p>
							<span id="name.info" style="color:red"></span>
						</div></td>
				</tr>
				<tr>
					<td valign="top" class="w1">收件人详细地址：</td>
					<td><input onblur="checkeaddress()" type="text"
						name="address" class="text_input" id="fullAddress" />
						<div class="text_left" id="addressValidMsg">
							<p>请填写有效的收件人的详细地址</p>
							<span id="address.info" style="color:red"></span>
						</div></td>
				</tr>
				<tr>
					<td valign="top" class="w1">手机</td>
					<td><input onblur="checkphone()" type="text"
						class="text_input" name="mobile" id="phone" />
						<div class="text_left" id="phoneValidMsg">
							<p>请填写有效的收件人的手机</p>
							<span id="telphone.info" style="color:red"></span>
						</div></td>
				</tr>
			</table>

			<div class="login_in">
				<a href="javascript:history.go(-1);"><input id="btnClientRegiste"
					class="button_1"  type="button" value="返回" /></a> <input
					id="btnClientRegister" class="button_1" name="submit" type="submit"
					value="添加" />
			</div>
		</form>
	</div>
	<%@include file="../common/foot1.jsp"%>
<script type="text/javascript">
	function checkname() {
		let inpu = document.querySelector("#receiveName")
		let span = document.querySelector("#name\\.info")
		let reg = /([\u4E00-\u9FA5]|[a-z0-9]{2}){2,10}/
		if(reg.test(inpu.value)){
			span.innerHTML="姓名格式正确"
			span.style.color="green"
			return true
		}else{
			span.innerHTML="姓名格式错误"
			span.style.color="red"
			return false
		}
	}
	function checkeaddress(){
		let inpu = document.querySelector("#fullAddress")
		let span = document.querySelector("#address\\.info")
		let reg = /([\u4e00-\u9fa5\s]+)省([\u4e00-\u9fa5\s]+)市([\u4e00-\u9fa5\s]+)(区|县)([\u4e00-\u9fa5\s]+)(街道|路|乡|镇|号|$)/
		if(reg.test(inpu.value)){
			span.innerHTML="地址格式正确"
			span.style.color="green"
			return true
		}else{
			span.innerHTML="地址格式错误"
			span.style.color="red"
			return false
		}
	}
	function checkphone() {
		let inpu = document.querySelector("#phone")
		let span = document.querySelector("#telphone\\.info")
		let reg = /^(((13[0-9])|(14[579])|(15([0-3]|[5-9]))|(16[6])|(17[0135678])|(18[0-9])|(19[89]))\d{8})$/
		if(reg.test(inpu.value)){
			span.innerHTML="手机号格式正确"
			span.style.color="green"
			return true
		}else{
			span.innerHTML="手机号格式错误"
			span.style.color="red"
			return false
		}
	}
	function checkForm() {
		return checkname()&&checkeaddress()&&checkphone()
	}
</script>
</body>
</html>

